package com.example.demozmq.controller;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.OptionalDouble;

public class Test1 {

    public static void main(String[] args) {
        List<Double> aList = buildList();
        OptionalDouble aMax = aList.stream().mapToDouble(d -> d).max();
        OptionalDouble aMin = aList.stream().mapToDouble(d -> d).min();
        double aMaxValue = aMax.getAsDouble();
        double aMinValue = aMin.getAsDouble();
        System.out.println("实际b值最大值：" +  aMaxValue);
        System.out.println("实际b值最小值：" +  aMinValue);


        List<Double> tList = buildTList();
        OptionalDouble tMax = tList.stream().mapToDouble(d -> d).max();
        OptionalDouble tMin = tList.stream().mapToDouble(d -> d).min();
        double tMaxValue = tMax.getAsDouble();
        double tMinValue = tMin.getAsDouble();
        System.out.println("标准b值最大值：" +  tMaxValue);
        System.out.println("标准b值最小值：" +  tMinValue);

        BigDecimal multiply = BigDecimal.valueOf(aMaxValue - aMinValue).multiply(BigDecimal.valueOf(100)).divide(BigDecimal.valueOf(tMaxValue - tMinValue), 2, RoundingMode.HALF_UP);
        System.out.println(multiply + "%");
    }

    public static List<Double> buildList () {
        List<Double> aList = new ArrayList<>();
        aList.add(69.00);
        aList.add(68.00);
        aList.add(68.00);
        aList.add(69.00);
        aList.add(69.00);
        aList.add(68.00);
        aList.add(69.00);
        aList.add(69.00);

        return aList;
    }

    public static List<Double> buildTList () {
        List<Double> bList = new ArrayList<>();
        bList.add(160.88);
        bList.add(162.01);
        bList.add(163.82);
        bList.add(165.97);
        bList.add(167.91);
        bList.add(169.17);
        bList.add(171.60);
        bList.add(175.18);

        return bList;
    }
}
